package com.ruoyi.epidemic.service.impl;

import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.epidemic.domain.EpidemicControlDept;
import com.ruoyi.epidemic.domain.EpidemicUserDept;
import com.ruoyi.epidemic.domain.WxCpSysUser;
import com.ruoyi.epidemic.mapper.EpidemicControlDeptMapper;
import com.ruoyi.epidemic.mapper.EpidemicWriteDeptMapper;
import com.ruoyi.epidemic.service.IEpidemicWriteDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.ruoyi.common.utils.ShiroUtils.getLoginName;

@Service
public class EpidemicWriteDeptServiceImpl implements IEpidemicWriteDeptService {

    @Autowired
    private EpidemicWriteDeptMapper epidemicWriteDeptMapper;

    @Override
    public List<WxCpSysUser> selectWriteUserList(WxCpSysUser wxCpSysUser) {
        return epidemicWriteDeptMapper.selectWriteUserList(wxCpSysUser);
    }

    @Override
    public int selectCountByUserIdAndDeptId(Long userId, Long deptId) {
        return epidemicWriteDeptMapper.selectCountByUserIdAndDeptId(userId,deptId);
    }

    @Override
    public int insertWriteUserDept(EpidemicUserDept epidemicUserDept)
    {
        epidemicUserDept.setCreateTime(DateUtils.getNowDate());
        epidemicUserDept.setCreateBy(getLoginName());
        return epidemicWriteDeptMapper.insertWriteUserDept(epidemicUserDept);
    }

    @Override
    public int deleteWriteUserDeptByIds(String ids) {
        return epidemicWriteDeptMapper.deleteWriteUserDeptByIds(Convert.toStrArray(ids));
    }

    @Override
    public WxCpSysUser selectWriteUser(Long id) {
        return epidemicWriteDeptMapper.selectWriteUser(id);
    }

    @Override
    public int updateWriteUserDept(EpidemicUserDept epidemicUserDept) {
        epidemicUserDept.setUpdateTime(DateUtils.getNowDate());
        epidemicUserDept.setUpdateBy(getLoginName());
        return epidemicWriteDeptMapper.updateWriteUserDept(epidemicUserDept);
    }
}
